/-app ...
/-app/tests ...
TestCase.ts
TestPage.ts
Application.ts
/-boot
/-imports
/-storage
/-tests
/-typings
stringUtils.ts
teapo.html
1
module teapo.app.tests {
2
 
3
  export class TestPage {
4
 
5
    tests: TestCase[] = [];
6
 
7
    constructor(
8
      namespace: any = teapo.app.tests,
9
      private _queueWorkItem: (action: () => void) => void = action => setTimeout(action, 10)) {
10
 
11
      this._loadTests(namespace);
12
 
13
    }
14
 
15
    private _loadTests(namespace: any) {
16
 
17
      var byName: { [name: string]: TestCase; } = {};
18
      var names: string[] = [];
19
 
20
      TestPage.forEachTest(namespace, (name, test) => {
21
        var testCase = new TestCase(name, test);
22
        byName[name] = testCase;
23
        names.push(name);
24
      });
25
 
26
      names.sort();
27
      names.forEach(name => {
28
        var testCase = byName[name];
29
        this.tests.push(testCase);
30
      });
31
 
32
    }
33
 
34
    static forEachTest(namespace: any, callback: (name: string, test: () => void) => void) {
35
      for (var k in namespace) if (namespace.hasOwnProperty(k)) {
36
        var t = namespace[k];
37
        if (typeof (t) === 'function') {
38
          callback(k, t);
39
        }
40
      }
41
    }
42
  }
43
 
44
}